package com.jia.explore.recursion;

import java.util.Arrays;

/**
 * @program: Leetcode
 * @description: 冒泡递归实现
 * @author: STU756
 * @create: 2020-08-17 16:03
 */
public class Bubble {
    public static void bubble(int[] a, int L, int R){
        if(L < R) {
            for(int i = L; i < R; i++) {
                if(a[i]>a[i+1]) {
                    int temp = a[i];
                    a[i] = a[i+1];
                    a[i+1] = temp;
                }
            }
            bubble(a, L, R - 1);
        }

    }

    public static void main(String[] args) {
        int[] a = {3,4,5,7,2,4,7,8,9,2,4};
        bubble(a, 0, a.length - 1);
        System.out.println(Arrays.toString(a));
    }
}
